lp564920-fix-big-files
authorDebian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Sat, 2 May 2015 08:26:54 +0000 (10:26 +0200)
committerOndřej Surý <ondrej@debian.org>
Sat, 11 Apr 2026 07:08:00 +0000 (09:08 +0200)
Gbp-Pq: Name 0013-lp564920-fix-big-files.patch

main/streams/plain_wrapper.c

index b6c117c52e202f54cd9462596ff16c1ae17f8a3e..e6a7c0923a04c87f23c529dcb9a17a146207f679 100644 (file)
@@ -796,7 +796,13 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
 
                                switch (value) {
                                        case PHP_STREAM_MMAP_SUPPORTED:
-                                               return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
+                                               if (fd == -1)
+                                                       return PHP_STREAM_OPTION_RETURN_ERR;
+                                               /* Don't mmap large files */
+                                               do_fstat(data, 1);
+                                               if (data->sb.st_size > 4 * 1024 * 1024)
+                                                       return PHP_STREAM_OPTION_RETURN_ERR;
+                                               return PHP_STREAM_OPTION_RETURN_OK;
 
                                        case PHP_STREAM_MMAP_MAP_RANGE:
                                                if (do_fstat(data, 1) != 0) {